<template>
  <div class="rights">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>角色列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-table
        v-loading="isLoading"
        :data="rightList"
        border
        style="width: 100%"
      >
        <el-table-column type="index" width="50" label="#"> </el-table-column>
        <el-table-column prop="authName" label="权限名称" width="180">
        </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column label="权限等级">
          <template slot-scope="scope">
              <el-tag size="mini" :type = "scope.row.level == 0? 'info':scope.row.level == 1 ? '':'danger'">
                {{ scope.row.level | fmtLevel}}
              </el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getRightList } from "../../api/index";
export default {
  data() {
    return {
      isLoading: false, //加载中显示
      rightList: [],
    };
  },
  created() {
    this.getRights();
  },
  methods: {
    async getRights() {
      this.isLoading = true;
      let res = await getRightList({ type: "list" });
      let {
        data,
        meta: { msg, status },
      } = res;
      if (status == 200) {
        this.rightList = data;
        this.isLoading = false;
      }
    },


  },
  filters: {
    fmtLevel(level,colorType) {
      if (level === "0") {
        return "一级";
      } else if (level === "1") {
        colorType = ""
        return "二级";
      } else {
        colorType = "danger"
        return "三级";
      }
    },
  },
};
</script>

<style lang="less" scoped>
.el-breadcrumb {
  background-color: initial;
  font-size: 12px;
  line-height: initial;
  height: initial;
  padding: 0px;
}

.el-card__body {
  min-width: 400px;
}

.el-table {
  margin-top: 20px;
  overflow: auto;
}
.el-pagination {
  margin-top: 20px;
}
</style>